﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IQKS.AWP.BusinessAccessLayer;
using IQKS.AWP.BusinessObject;

public partial class home_PaymentStatus : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (Session["PaymentStatusID"] != null) //add
                {
                    int intStatusID = Convert.ToInt32(Session["PaymentStatusID"]);
                    GetData(CommonUtility.GetLoggedOnUserId(), intStatusID);
                   
                }
                else
                {

                }

            }
            catch (Exception)
            {
                // Response.Redirect("");
            }
        }

    }
    private void GetData(Guid UID, int StatusID)
    {
        DataSet objDs;
        objDs = new PaymentInvoiceBAL().GetPaymentStatusDetailUserWise(UID, StatusID);
        if (StatusID==0)
        {
            gvUnpaidInvoices.DataSource = objDs;
            gvUnpaidInvoices.DataBind();
            string strUserRole = CommonUtility.GetCurrentUserRole();
            if (strUserRole != "IQKSAD" && strUserRole != "IQKSMG")
            {
                gvUnpaidInvoices.Columns[5].Visible = false;
                gvUnpaidInvoices.Columns[6].Visible = false;
            }
        }
        else
        {
            gvPaidInvoices.DataSource = objDs;
            gvPaidInvoices.DataBind();
            string strUserRole = CommonUtility.GetCurrentUserRole();
            if (strUserRole != "IQKSAD" && strUserRole != "IQKSMG")
            {
                gvPaidInvoices.Columns[5].Visible = false;
                gvPaidInvoices.Columns[6].Visible = false;
            }
        }

        

    }

    protected void gvPaidInvoices_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvPaidInvoices.PageIndex = e.NewPageIndex;
        GetData(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(Session["PaymentStatusID"]));

    }
    protected void gvUnpaidInvoices_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvUnpaidInvoices.PageIndex = e.NewPageIndex;
        GetData(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(Session["PaymentStatusID"]));
    }
}